﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLogicLayer;

namespace logicunivesityinventorystore.Department
{
    public partial class ViewOrderDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindGridView();
            if(gvOrderList.Rows.Count==0)
            {
                lblOrderList.Visible = false;
            ScriptManager.RegisterStartupScript(this, typeof(string), "Error", "alert('There is no order details now!');window.location.href = 'HomePage_Department.aspx'", true);
            }
        }

        private void BindGridView()
        {
            gvOrderList.DataSource = new RequisitionFacade().FindByApprove(User.Identity.Name);
            gvOrderList.DataBind();
        }

        protected void lbtnFormID_Click(object sender, EventArgs e)
        {
          
        }

        protected void gdOrderList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string formID = (e.Row.FindControl("lbtnFormID") as LinkButton).Text;
                (e.Row.FindControl("lbtnFormID") as LinkButton).Attributes.Add("onClick", "ShowEditModal('OrderDetail.aspx?RequisitionID=" + formID + "');");

            }
        }

 
    }
}